package com.example.message.response;

public class Response {

    private Integer code;

    private String message;

    private Object data;

    private Long total;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Response(){}

    public Response(Integer code){this.code = code;}

    public Response(Integer code, String message, Object data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Response success(){
        this.setResponseCode(ResponseCodeEnum.SUCCESS);
        return this;
    }
    public Response success(Object data){
        this.setData(data);
        this.setResponseCode(ResponseCodeEnum.SUCCESS);
        return this;
    }
    public Response setResponseCode(ResponseCodeEnum responseCode){
        this.code = responseCode.code();
        this.message = responseCode.message();
        return this;
    }
}
